package com.bgs.service.impl;

import com.alibaba.fastjson.JSON;
import com.bgs.ThreeConfig.DirectExchangeTestThreeMoney;
import com.bgs.pojo.China;
import com.bgs.mapper.ChinaMapper;
import com.bgs.service.ChinaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Asia
 * @since 2021-09-14
 */
@Service
public class ChinaServiceImpl extends ServiceImpl<ChinaMapper, China> implements ChinaService {

    @Resource
    private ChinaMapper chinaMapper;

    @RabbitListener(queues = DirectExchangeTestThreeMoney.MONEY_DIRECT_EXCHANGE_QUEUE_NAME)
    public void DetailThree(Message msg) {
        String body = new String(msg.getBody());
        HashMap<String, String> res = JSON.parseObject(body, HashMap.class);
        Object userid = res.get("userid");
        int befId = Integer.parseInt(userid.toString());
        Object zonge = res.get("zonge");
        Double Money = Double.parseDouble(zonge.toString());
        boolean ba = chinaMapper.BefUser(befId, Money);

    }


}
